<?php
class GlobalAction extends Action {
    public function __construct(){
		
        $this->noie();
        
        $this->assign('bg_rand', rand(1, 3));
        $this->setLang();
	}
	
    protected function setLang() {
        $this->lang = L('lang');
        $this->assign('lang', $this->lang);
    }
	
    //是否IE6,7,8
    protected function isBadIE() {
        preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches);
        if (count($matches)>1){
            $version = intval($matches[1]);
            return $version<=7? true : false;
        } else {
            return false;
        }
    }
    
    //No IE
    private function noie() {
        if ($this->isBadIE() && !isset($_COOKIE['ignore_ie'])){
            $this->redirect('Error/noie', array(
                'r' => base64_encode($_SERVER['REQUEST_URI'])   //记录下请求页面
            ));
            exit();
        }
    }
}